/**
 * 日期格式化
 *  @author auauoo
 * @param {String} date  待格式化的数据 2021-11-26 10:56:00
 * @return String
 */
function dateFormat(date){
    var oldDate = new Date(date)
    var newDate = new Date()
    var diff = parseInt((newDate.getTime()-oldDate.getTime())/1000)
    //console.log(diff)
    if(diff<10){
        return '刚刚'
    }else if(diff>=10 && diff<60){
        return diff + '秒前'
    } else if(diff>=60 && diff <3600){
        return parseInt(diff/60)+'分钟前'
    } else{
        return '不在计算范围内'
    }
    
}
//console.log(dateFormat('2021-11-26 10:56:00'))


/**
 * 判断浏览器内核
 * @return Object
 */
function browser() {  
    var u = navigator.userAgent;
    return {
        trident: u.indexOf('Trident') > -1, //IE内核
        presto: u.indexOf('Presto') > -1, //opera内核
        webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
        gecko: u.indexOf('Firefox') > -1, //火狐内核Gecko
        mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
        ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios
        android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android
        iPhone: u.indexOf('iPhone') > -1 , //iPhone
        iPad: u.indexOf('iPad') > -1, //iPad
        webApp: u.indexOf('Safari') > -1, //Safari
        chrome:u.indexOf('Chrome') > -1
    };
}

/**
 * 现在是PC还是移动
 * @return String
 */
var isM = function () {
    var u = navigator.userAgent;
　　if (u.indexOf('Android') > -1 || u.indexOf('iPhone') > -1 || u.indexOf('iPod') > -1 || u.indexOf('Symbian') > -1 || !!u.match(/AppleWebKit.*Mobile.*/)){
    　　　　return '现在是移动端';}else{
    　　　　return '现在是pc端';
    　　}
};

/**
 * 判断是否是微信浏览器
 * @return String
 */
function WeiXin () {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == "micromessenger") {
        return '是微信浏览器';
    }else{
        return '不是微信浏览器'
    }
}
   
    